sim: Fix linker support and macOS host build issues#18331
sim: Fix linker support and macOS host build issues#18331xiaoxiang781216 merged 1 commit intoapache:masterfrom
Conversation
|
Hi @aditya0yadav , I converted PR into draft. @FelipeMdeO @lupyuen @aviralgarg05 What do you think? |
|
please remove the merge commit ! |
Hi @simbit18, thanks for tagging me, the core approach of using |
|
@aviralgarg05 I’ve removed the #define _POSIX_C_SOURCE 200809L in macOS and Ubuntu-based code spaces and it’s working properly. Mind taking a look? |
|
@simbit18 One more thing, what should we do with the linker in macOS? Every time I have to disable the configuration toolchain related to Gcov. Any suggestions? |
Thanks for the update @aditya0yadav, I checked the latest changes, the approach looks correct. There might be an issue with the |
|
Thanks for the review, @aviralgarg05.
I will look into it .
|
A long time ago, it was possible to build sim:nsh for Linux, macOS, and Windows . Of course, this is just my opinion! :) |
I think is makes sense, maybe using git bisect it could be possible to identify which symbols cases the breaking and open an issue to track it. |
|
Hi @raiden00pl, The changes in this PR cause errors in sim:citest. Can you check it? |
|
@simbit18 @aditya0yadav sim/citest is broken, NTFC detects that device is broken at init or doesn't boot at all. When I run binary from this PR, NSH is not functional and it stucks on NSH prompt (not sure what is this init error and if it's realted):
probably not everyone knows about it, but you can download built binaries directly from CI:
|
|
with this PR |
|
@raiden00pl, thank you very much. |
I just want to check if I’m understanding correctly: The linker issue seems to happen only on macOS, not on Linux. On Linux, it works fine and uses Gcov as expected, but on macOS, I always have to disable the Gcov-related toolchain in the configuration. If I wanted to find the specific symbol that is causing the linker to fail, doing a git bisect over 2–4 years of changes seems impractical because there’s been too much change in the repository. One idea I had is to use Docker with Linux to build NuttX, since Linux doesn’t hit the macOS linker problem. But of course, that wouldn’t reproduce the macOS-specific issue. Do you have any suggestions on how to approach this efficiently for macOS? |
|
Hello all,
Sorry for late reply.
I am very busy during this week but this weekend I will be available to
help. Let me try execute de bisec and find the valid commit.
*Felipe Moura de Oliveira*
*Universidade Federal de Minas Gerais*
Linkedin <https://www.linkedin.com/in/felipe-oliveira-75a651a0>
<https://twitter.com/FelipeMOliveir?lang=pt-br>
…On Thu, 5 Feb 2026 at 19:04 Aditya Yadav ***@***.***> wrote:
*aditya0yadav* left a comment (apache/nuttx#18331)
<#18331 (comment)>
@simbit18 <https://github.com/simbit18> One more thing, what should we do
with the linker in macOS? I know it will work perfectly with Linux but not
with macOS.
Every time I have to disable the configuration toolchain related to Gcov.
Any suggestions?
A long time ago, it was possible to build sim:nsh for Linux, macOS, and
Windows . Currently, it does not work on macOS and Windows with
MSYS2/Cygwin (the latest version I was able to build and test was 10.2
<https://github.com/simbit18/nuttx-msys2>), so I personally think it is
right to restore the build by modifying the defconfig file.
Of course, this is just my opinion! :)
I think is makes sense, maybe using git bisect it could be possible to
identify which symbols cases the breaking and open an issue to track it.
I just want to check if I’m understanding correctly:
@simbit18 <https://github.com/simbit18> @acassis
<https://github.com/acassis>
The linker issue seems to happen only on macOS, not on Linux. On Linux, it
works fine and uses Gcov as expected, but on macOS, I always have to
disable the Gcov-related toolchain in the configuration.
If I wanted to find the specific symbol that is causing the linker to
fail, doing a git bisect over 2–4 years of changes seems impractical
because there’s been too much change in the repository.
One idea I had is to use Docker with Linux to build NuttX, since Linux
doesn’t hit the macOS linker problem. But of course, that wouldn’t
reproduce the macOS-specific issue.
Do you have any suggestions on how to approach this efficiently for macOS?
—
Reply to this email directly, view it on GitHub
<#18331 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADNC5ZRBKU6VDMZIY5VHU634KO47NAVCNFSM6AAAAACTY7CVNWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQNJWGUZDMOBSHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Hello @aditya0yadav , @acassis , @simbit18 , @raiden00pl, @linguini1 . I did several build to try get first macOS build break. The last OK macOS build (commit sha): Crash Commit SHA: Using this SHA, the build output is: |
|
@simbit18 @raiden00pl any idea what is this error: I just restarted the CI, let's see if it helps |
|
@acassis because this change breaks sim and nuttx sim doesn't even boot on CI linux ( |
|
@acassis you can download sim elf here and run on linux: https://github.com/apache/nuttx/actions/runs/22508690590/job/65219879041#step:14:25 NSH boots OK, but the system is not functional (you can press ENTER and nothing happen, the same issue like before) |
Thank you @raiden00pl so it is not a false positive. @aditya0yadav @FelipeMdeO did you test it? |
|
Simple sim/nsh config boots fine, but sim/citest config is broken |
Hello @aditya0yadav @xiaoxiang781216 using my last commit the system work properly on macos and linux, I tested both using ostest. Please consider back to this version, make rebase + squash, test again and if everything is ok, add xiaoxiang changes. |
|
@aditya0yadav the CI is failing because: You didn't signed your commit and you are using "sim: posix:" instead of "sim/posix:" in the commit title. Please fix these issues. |
21c0030
Update SIM configuration and CMake toolchain to resolve linker errors when building on macOS. Adjust POSIX host implementation to ensure successful compilation and proper behavior of the sim target. Modified: - arch/sim/Kconfig - arch/sim/src/cmake/Toolchain.cmake - arch/sim/src/sim/posix/sim_hostmisc.c Signed-off-by: Aditya Yadav <166515021+aditya0yadav@users.noreply.github.com>
|
@FelipeMdeO @acassis @xiaoxiang781216
Done |
|
Thank you @aditya0yadav nice contribution! |
|
I want thank you too @aditya0yadav , this solution is very important for our repo! |
|
Hi @aditya0yadav @FelipeMdeO , check our NuttX mirror. The build on macOS still doesn't seem to be working properly! https://github.com/NuttX/nuttx/actions/runs/22726058364/job/65901687969#logs |
|
@simbit18 that pr right now fixes the issue related to the linker on mac |
|
@aditya0yadav Ok, so the original intent of the PR does not match the final result. sim: Fix linker support and macOS host build issues |
|
@simbit18 thanks |



PLEASE DONT MERGE THIS PR
Summary
This change updates the POSIX simulator host timer implementation to
handle platform differences between macOS (Darwin) and Linux.
macOS does not provide full support for POSIX timers such as
timer_create()andtimer_settime(). To address this, the simulatornow uses
setitimer()on macOS while retaining POSIX timers withabsolute-time scheduling on Linux and other POSIX systems.
The platform selection is handled via the
NUTTX_DARWINmacro, keepingthe simulator core logic unchanged while improving portability and
correctness on macOS.
Impact
Testing
Tested on macOS (Darwin):
SIGALRMand simulatorscheduling behaves as expected.
Linux testing:
Since this change affects host timer handling, additional testing on
Linux systems would be valuable before merging.
If anyone is able to test this change on a Linux PC and confirm that the
POSIX simulator builds and runs correctly, that feedback and any logs
would be greatly appreciated.
One more thing ,
For supporting macos, multiple things need to be done like docs and linker too .